package chooongg.base.utils

import android.telephony.TelephonyManager
import chooongg.base.Utils

object PhoneUtils {

    fun isPhone(): Boolean {
        return Utils.app.getTelephonyManager().phoneType != TelephonyManager.PHONE_TYPE_NONE
    }

    fun isSimCardReady(): Boolean {
        return Utils.app.getTelephonyManager().simState == TelephonyManager.SIM_STATE_READY
    }

    fun getSimOperatorName() = Utils.app.getTelephonyManager().simOperatorName

    fun getSimOperatorByMnc(): String? {
        val operator = Utils.app.getTelephonyManager().simOperator ?: return ""
        return when (operator) {
            "46000", "46002", "46007", "46020" -> "中国移动"
            "46001", "46006", "46009" -> "中国联通"
            "46003", "46005", "46011" -> "中国电信"
            else -> operator
        }
    }

}